/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    ListNode* mergeTwoLists(ListNode* list1, ListNode* list2) {
        vector<int> temp;
        ListNode*act1=list1;
        ListNode*act2=list2;
        while(act1) {
            temp.push_back(act1->val);
            act1=act1->next;
        }
        while(act2) {
            temp.push_back(act2->val);
            act2=act2->next;
        }
        sort(temp.begin(),temp.end());
        ListNode sss(0);
        ListNode* ret= &sss;
        for(auto e: temp) {
            ret->next = new ListNode(e);
            ret=ret->next;
        }
        return sss.next;
    }
};